package com.xueyi.aixihu.service.impl;

import com.xueyi.aixihu.exception.SzException;
import com.xueyi.aixihu.response.UploadImageResponse;
import com.xueyi.aixihu.service.UploadFileService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletRequest;

/**
 * @author LuQi
 * @类描述 上传文件
 * @时间 2021/11/7
 */
@Service
@Slf4j
public class UploadFileServiceImpl implements UploadFileService {

    @Autowired
    HttpServletRequest request;

    private static final String UPLOAD_IMAGE_VIDEO = "up_iv_account";
    private static final String UPLOAD_IMAGE_VIDEO_VALUE = "UPLOAD_IMAGE_VIDEO_VALUE";

    @Override
    public String uploadImageOrVideo(MultipartFile file) throws SzException {


        // 参数校验，校验token是否存在
        UploadImageResponse upload = UploadImageResponse.build().upload(file,
                UploadImageResponse.UploadImageStatus.SZ_IV);
        return upload.getUrl();
    }
}
